const path = require("path");

const entry = {
    "base" : "./src/index.js",
    "parts/inc/header" : "./src/parts/inc/header.js",
    "libs/jquery" : "jquery",
    "routes/login/login": "./src/routes/login/login.js"
}

const output = {
      path : path.resolve(__dirname,"../dev"),
      filename : "[name]-[hash:4].js"
}

// 处理html
const htmlPlugin = [
    {
        filename : "index.html",
        template : "./src/index.html",
        chunks: ['base']
    }
    ,
    {
        filename : "parts/inc/header.html",
        template : "./src/parts/inc/header.html",
        chunks: ["parts/inc/header"],
    }
    ,
    {
        filename : "routes/login/login.html",
        template : "./src/routes/login/login.html",
        chunks: ['routes/login/login']
    }
    ,
]

// 将jquery等插件全局化
const providePlugin = [
    {
        $: "jquery",
        jQuery: "jquery",
        jquery: "jquery",
        "window.jQuery": "jquery"
    }
];

// 服务器代理配置;
const proxyList = {
    "/pxx" : {
            url : "https://apiv2.pinduoduo.com/api/fiora/subject/goods/",
            // 默认重写路径
            // rewrite : true
    },
    "/dt" :{
            url : "https://www.duitang.com/napi/blog/list/by_filter_id/"
    }
}

// 自动打开html
const openBrowser = { url: 'http://localhost:8888' };

module.exports = {
    entry,
    output,
    htmlPlugin,
    providePlugin,
    openBrowser,
    proxyList
}